package com.ruoyi.comment.controller;

import com.ruoyi.comment.domain.Assess;
import com.ruoyi.comment.service.IAssessService;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 医生评价管理Controller
 * 
 * @author ruoyi
 * @date 2025-08-13
 */
@RestController
@RequestMapping("/comment/assess")
public class AssessController extends BaseController
{
    @Autowired
    private IAssessService assessService;

    /**
     * 查询医生评价管理列表
     */
    @PreAuthorize("@ss.hasPermi('comment:assess:list')")
    @GetMapping("/list")
    public TableDataInfo list(Assess assess)
    {
        startPage();
        List<Assess> list = assessService.selectAssessList(assess);

        return getDataTable(list);
    }

    /**
     * 导出医生评价管理列表
     */
    @PreAuthorize("@ss.hasPermi('comment:assess:export')")
    @Log(title = "医生评价管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Assess assess)
    {
        List<Assess> list = assessService.selectAssessList(assess);
        ExcelUtil<Assess> util = new ExcelUtil<Assess>(Assess.class);
        util.exportExcel(response, list, "医生评价管理数据");
    }

    /**
     * 获取医生评价管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('comment:assess:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(assessService.selectAssessById(id));
    }

    /**
     * 新增医生评价管理
     */
    @PreAuthorize("@ss.hasPermi('comment:assess:add')")
    @Log(title = "医生评价管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Assess assess)
    {
        return toAjax(assessService.insertAssess(assess));
    }

    /**
     * 修改医生评价管理
     */
    @PreAuthorize("@ss.hasPermi('comment:assess:edit')")
    @Log(title = "医生评价管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Assess assess)
    {
        return toAjax(assessService.updateAssess(assess));
    }

    /**
     * 删除医生评价管理
     */
    @PreAuthorize("@ss.hasPermi('comment:assess:remove')")
    @Log(title = "医生评价管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(assessService.deleteAssessByIds(ids));
    }
    @GetMapping("my")
    public AjaxResult getMyAssess(@RequestParam Long patientId) {
    // 实际项目中建议从登录态中获取patientId，避免前端传递
    List<Assess> assessList = assessService.getMyAssessList(patientId);
    return AjaxResult.success(assessList);
}
}
